package org.noear.solon.ai.flow.components.repositorys;

import com.fliad.ai.service.AiDocumentService;
import org.noear.solon.ai.rag.RepositoryStorable;
import org.noear.solon.annotation.Component;
import org.noear.solon.flow.FlowContext;
import org.noear.solon.flow.Node;

@Component("InjectRepositoryCom")
public class InjectRepositoryCom extends AbsRepositoryCom {

    @Override
    public RepositoryStorable getRepository(FlowContext context, Node node) throws Throwable {
        //构建知识库（预热后，会缓存住）
        RepositoryStorable repository = (RepositoryStorable) node.attachment;
        if (repository == null) {
            repository = AiDocumentService.KNOWLEDGE_REPO.get(Long.valueOf(node.getMeta("knowId")));
        }
        return repository;
    }

}
